package com.codebuffer.nowcoder;

import java.util.ArrayList;

public class FindNumbersWithSum {
    public ArrayList<Integer> FindNumbersWithSum(int [] array, int sum) {
        ArrayList<Integer> integers = new ArrayList<>();
        for (int i = 0; i < array.length; i++) {
            for (int i1 = array.length - 1; i1 > i; i1--) {
                if(array[i]+array[i1]==sum){
                    integers.add(array[i]);
                    integers.add(array[i1]);
                    return integers;
                }
            }
        }
        return integers;
    }
}
